prepare("SELECT * FROM events WHERE sn = ?"); $stmt->execute([$sn]); $event = $stmt->fetch(PDO::FETCH_ASSOC); } catch(PDOException $e) { $_SESSION['error'] = "Error loading event: " . $e->getMessage(); header("location: events"); exit(); } } if(!$event) { $_SESSION['error'] = "Event not found!"; header("location: events"); exit(); } // Handle form submission if(isset($_POST['update_event'])) { $caption = sanitize_input($_POST['caption']); $content = sanitize_input($_POST['content']); $event_date = sanitize_input($_POST['event_date']); $event_time = sanitize_input($_POST['event_time']); $event_location = sanitize_input($_POST['event_location']); // Validation $errors = []; if(empty($caption)) { $errors[] = "Event caption is required"; } if(empty($event_date)) { $errors[] = "Event date is required"; } if(empty($event_time)) { $errors[] = "Event time is required"; } if(empty($event_location)) { $errors[] = "Event location is required"; } if(empty($errors)) { try { $stmt = $DBcon->prepare("UPDATE events SET caption = ?, content = ?, event_date = ?, event_time = ?, event_location = ? WHERE sn = ?"); $stmt->execute([$caption, $content, $event_date, $event_time, $event_location, $sn]); $_SESSION['success'] = "Event updated successfully!"; header("location: events"); exit(); } catch(PDOException $e) { $_SESSION['error'] = "Error updating event: " . $e->getMessage(); } } else { $_SESSION['error'] = implode("
", $errors); } } ?> School Admin

Edit Event Information

Update the event details

Maximum 200 characters
Cancel Delete Event

Event Summary

Status:
Past Event Happening Today! Upcoming Event

Created:

Time Until Event:
0) { echo "{$days} day" . ($days > 1 ? 's' : '') . " and {$hours} hour" . ($hours > 1 ? 's' : ''); } else { echo "{$hours} hour" . ($hours > 1 ? 's' : ''); } } ?>